package com.reeygu.generator.file;

import com.reeygu.model.MainTemplateConfig;
import com.reeygu.utils.GeneratorDynamicFile;
import com.reeygu.utils.GeneratorStaticFile;
import com.reeygu.utils.GetPath;

/**
 * @describe: 用于测试生成功能
 * @author: ReeyGu
 * @data: 2024/3/30 19:28
*/
public class GeneratorMainTemplate {
    public static void main(String[] args) throws Exception {
        doGenerator(null);
    }

    public static void doGenerator(MainTemplateConfig mainTemplateConfig) throws Exception {
        String in = GetPath.toPath("reeygu-generator-code-demo/acm-template");
        String out = GetPath.toPath("reeygu-generator-maker/src/main/resources/ftlsOutput");
        // 先生成静态文件
        String url = GeneratorStaticFile.copyFilesByRecursive(in, out);
        System.out.println(in + " " + out);
        System.out.println(url);

        // 文件相对路径
        String srcUrl = GetPath.toPath("reeygu-generator-maker/src/main/resources/ftls");
        // 模板文件
        String fileName = "MainTemplate.java.ftl";
        // 输出地址
        String outputName = "E:\\Desktop\\item\\reeygu-generator-code\\reeygu-generator-maker\\src\\main\\resources\\ftlsOutput\\acm-template\\src\\com\\reeygu\\acm\\MainTemplate.java";
        // 模板参数
        if (mainTemplateConfig == null) {
            mainTemplateConfig = MainTemplateConfig
                    .builder()
                    .username("ReeyGu")
                    .answer("answer")
                    .isWhile(true)
                    .build();
        }


        // 再生成动态
        GeneratorDynamicFile.LoadConfiguration(srcUrl, fileName, outputName, mainTemplateConfig);
    }



}
